<template>
	<view class="item-container" :class="theme + ' ' + grid" @tap="toDetail" hover-class="hover">
		<!-- <image class="p-tag" src="@/static/new.png" v-if="tag == 'new'"></image> -->
		<view class="thumb-c">
			<image class="p-tag" :class="theme + ' ' + grid + ' location-' + info.pic.location"
				:src="info.pic" v-if="info.pic"></image>
			<image mode="aspectFill" :src="info.thumb" class="thumb"></image>
			<view class="presell-c" v-if="info.isPresell">预售</view>
			<view class="empty-stock" v-if="info.stock === 0">
				<image src="@/static/empty-stock.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="body">
			<view class="title">{{info.name}}</view>
			<view class="bottom">
				<template v-if="isShowTags">
					<template v-if="info.tags && info.tags.length">
						<view class="tag" v-for="(tag, index) in info.tags">{{tag}}</view>
					</template>
					<view class="tag" v-else>{{'人气新品'}}</view>
				</template>
				<view class="price">
					<!-- <PriceDisplay :info="info"></PriceDisplay> -->
					{{info.price?info.price:0}} 晶石
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			grid: {
				type: String,
				default () {
					return 'grid2'
				}
			},
			info: {
				type: Object,
				default () {
					return {}
				}
			},
			tag: {
				type: String
			},
			theme: {
				type: String,
				default () {
					return 'default-theme'
				}
			},
			isShowTags: {
				type: Boolean,
				default () {
					return true
				}
			}
		},
		data() {
			return {}
		},
		computed: {
			tagString() {
				return this.info && this.info.tags && this.info.tags[0] || '创意热销'
			}
		},
		methods: {
			toDetail() {
				uni.navigateTo({
					url: '/pages/productDetail/index?uuid=' + this.info.uuid
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item-container {
		// width: 230rpx;
		// height: 460rpx;
		// width: 30%;
		/* border-radius: 20rpx 20rpx 10rpx 10rpx; */
		/* border: 1rpx solid white; */
		overflow: hidden;
		margin-bottom: 24rpx;
		box-shadow: 0px 14px 30px 0px rgba(108, 67, 255, 0.4);
		position: relative;
		padding: 20rpx;
		// box-sizing: border-box;

		.thumb-c {
			position: relative;
			overflow: hidden;

			.thumb {
				// width: 100%;
				height: 210rpx;
				display: block;
				border-radius: 8rpx;
			}

			.presell-c {
				position: absolute;
				width: 100%;
				text-align: center;
				background: rgba(230, 49, 17, 0.5);
				color: white;
				left: 0rpx;
				bottom: 0rpx;
				font-size: 24rpx;
				padding: 6rpx 0rpx;
			}

			.p-tag {
				position: absolute;
				width: 70rpx;
				height: 70rpx;
				// right: 0rpx;
				top: 0rpx;
				border-radius: 8rpx;

				// 右上角
				&.location-1 {
					right: 0rpx;
				}

				// 右上角
				&.location-2 {
					left: 0rpx;
				}

				&.grid2 {
					width:100%;
					height:100%;
					// width: 300rpx;
					// height: 300rpx;
					// margin-left: 20rpx;
				}

			}

			.empty-stock {
				position: absolute;
				width: 100%;
				height: 100%;
				top: 0rpx;
				left: 0rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 50%;
				}

				background: rgba(0, 0, 0, 0.5);
			}
		}

		.body {
			padding: 4rpx 14rpx 10rpx 14rpx;
			box-sizing: border-box;

			.title {
				font-size: 26rpx;
				font-weight: 500;
				// color: #fff;
				// background-image: -webkit-linear-gradient(0deg, rgb(217, 163, 123), rgb(240, 206, 173), rgb(217, 163, 123));
				background-color: #fff;
				-webkit-background-clip: text;
				-webkit-text-fill-color: transparent;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
			}

			.tag {
				height: 36rpx;
				// 标签背景颜色
				// background: #fff;
				/* border-radius: 20rpx; */
				font-size: 24rpx;
				font-weight: 500;
				// color: #000;
				// background-image: -webkit-linear-gradient(0deg, rgb(217, 163, 123), rgb(240, 206, 173), rgb(217, 163, 123));
				background-color: #6c43ff;
				color: #fff;
				line-height: 36rpx;
				display: inline-block;
				padding: 2rpx 8rpx;
				margin-right: 5rpx;
				border-radius: 8rpx;
			}

			.price {
				text-align: right;
				font-size: 26rpx;
				font-weight: 800;
				color: #f1d3a8;
			}
		}

		
		&.grid2 {
			/* border-radius: 20rpx 20rpx 20rpx 20rpx; */

			.thumb {
				height: 310rpx;
			}

			.body {
				.title {
					font-size: 30rpx;
				}

				.price {
					text-align: right;
					font-size: 30rpx;
					font-weight: 800;
					color: #fff;
				}
			}
		}
		&.grid2:last-child{
			margin-bottom: 130rpx;
		}
	}

	// .theme-1 {
	// 	height: 400rpx;
	// 	.body {
	// 		border-radius: 20rpx;
	// 		overflow: hidden;
	// 		position: relative;
	// 		top: -30rpx;

	// 		.bottom {
	// 			display: flex;
	// 			align-items: center;
	// 			justify-content: space-between;
	// 		}
	// 	}
	// }
</style>